package com.songtech.alert.service.impl;

import com.songtech.alert.service.AlertService;
import com.songtech.server.Jedis.JedisBaseDao;
import com.songtech.server.constant.KeysConstant;
import com.songtech.server.constant.enumConstant.AlertEnum;
import com.songtech.server.entry.AlertEntry;
import com.songtech.base.redis.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AlertServiceImpl implements AlertService {

    @Autowired
    private RedisUtil redisUtil;

    @Autowired
    private JedisBaseDao jedisBaseDao;

    @Override
    public List<AlertEntry> getAlertInfo(String imei) throws Exception {


        StringBuffer stringBuffer = new StringBuffer(KeysConstant.ALERT);
        stringBuffer.append("_");
        stringBuffer.append(imei);
        Long endKey=jedisBaseDao.size(stringBuffer.toString());
        List<AlertEntry> list = jedisBaseDao.range(stringBuffer.toString(),0,new Long(endKey).intValue());
        return list;
    }
}
